package DataBase;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import DataObjects.MetaDataOrder;

public class SaveCommentsForATable {
	
	private MetaDataOrder metaDataOrder ;
	
	
	public SaveCommentsForATable(MetaDataOrder metaDataOrder)
	{
		this.metaDataOrder=metaDataOrder;
	}
	
	
	public int save()
	{
		int status=0;
		
		
		SQLConnection sc=new SQLConnection();
		try {
			
					
			PreparedStatement ps = sc.getConnection().prepareStatement("UPDATE table_timeslot SET comments=? WHERE orderId=?  ;");	
			sc.getConnection().setAutoCommit(false);
			ps.setString(1, metaDataOrder.getComments());
			ps.setInt(2,Integer.parseInt(metaDataOrder.getOrderId()));
			
			
			
			
			ps.executeUpdate();
			
			sc.getConnection().commit();
			sc.getConnection().close();
			ps.close();
			status=1;
		}
		
		catch (SQLException e) {
			// TODO Auto-generated catch block
			status=0;
			e.printStackTrace();
		}
		
		
		return status;
	}

}
